package com.chendx.store.search.mq.listenner;

import com.chendx.store.search.service.SearchService;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created by chendx on 2022/5/12.
 */
@RabbitListener(queues = "search_sku_update_queue")
@Component
public class SkuUpdateListenner {

    @Autowired
    private SearchService searchService;

    @RabbitHandler
    public void receiver(String message){
        System.out.println(message);
       /* if (!StringUtils.isEmpty(message)){
            Sku sku = null;
            try {
                sku = JSON.parseObject(message, Sku.class);
            } catch (Exception e) {
                e.printStackTrace();
                return;
            }
            if (sku == null){
                return;
            }
            SearchDto dto = new SearchDto();
            if (StringUtils.isEmpty(dto.getSkuId())){
                dto.setSkuId(String.valueOf(sku.getId()));
            }
            if (StringUtils.isEmpty(dto.getPrice())){
                dto.setPrice(dto.getPrice());
            }
            ResponseResult responseResult = searchService.update(dto);
        }*/
    }
}
